import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'

Vue.use(Router)
import Money from './money'
import platform from './platform'
import game from './game'

export const constantRouterMap = [{
  path: '/login',
  meta: {
    title: '登录',
    noCache: true
  },
  component: () => import('@/views/login'),
  hidden: true
},
{
  path: '/404',
  component: () => import('@/views/features/404'),
  hidden: true
},
{
  path: '/401',
  component: () => import('@/views/features/401'),
  hidden: true
},
{
  path: '/redirect',
  component: Layout,
  hidden: true,
  children: [{
    path: '/redirect/:path*',
    component: () => import('@/views/features/redirect')
  }]
},
{
  path: '/',
  component: Layout,
  redirect: '/dashboard',
  // redirect: '/customer/list'
  children: [{
    path: 'dashboard',
    component: () => import('@/views/home'),
    name: 'Dashboard',
    meta: {
      title: '首页',
      icon: 'index',
      affix: true,
      noCache: true
    }
  }]
},
// {
//   path: '/user',
//   component: Layout,
//   hidden: true,
//   redirect: 'noredirect',
//   children: [{
//     path: 'center',
//     component: () => import('@/views/system/user/center'),
//     name: '个人中心',
//     meta: {
//       title: '个人中心'
//     }
//   }]
// },
{
  path: '/components',
  component: Layout,
  children: [{
    path: 'icon',
    component: () => import('@/views/components/icons'),
    name: 'Icon',
    meta: {
      title: '图标库',
      icon: 'icon'
    }
  }]
}
]

export const asyncRouterMap = [{
  path: '',
  component: Layout,
  children: [
    {
      path: '/customer/list',
      name: 'customer',
      authority: 'customer',
      component: () => import('../views/customer'),
      meta: {
        title: '用户列表',
        noCache: true
      }
    }, {
      path: '/customer/detail',
      name: 'customerDetail',
      authority: 'customer',
      component: () => import('../views/customer/detail'),
      meta: {
        title: '用户详情',
        noCache: false
      }
    },
    // 权限
    {
      path: '/permission/user',
      name: 'permissionUser',
      authority: 'permissionUser',
      component: () => import('../views/permission/user'),
      meta: {
        title: '成员管理',
        noCache: false
      }
    }, {
      path: '/permission/role',
      name: 'permissionRole',
      authority: 'permissionRole',
      component: () => import('../views/permission/role'),
      meta: {
        title: '角色管理',
        noCache: false
      }
    }, {
      path: '/permission/menu',
      name: 'permissionMenu',
      authority: 'permissionMenu',
      component: () => import('../views/permission/menu'),
      meta: {
        title: '菜单管理',
        noCache: false
      }
    }, {
      path: '/permission/resource',
      name: 'permissionResource',
      authority: 'permissionResource',
      component: () => import('../views/permission/resource'),
      meta: {
        title: '资源管理',
        noCache: false
      }
    },
    // 运营
    {
      path: '/operation/notice',
      name: 'operationnotice',
      authority: 'notice',
      component: () => import('../views/operation/notice'),
      meta: {
        title: '公告管理',
        noCache: true
      }
    },
    // 软件包
    {
      path: '/software/list',
      name: 'softwarelist',
      authority: 'softwarelist',
      component: () => import('../views/software/list'),
      meta: {
        title: '软件包列表',
        noCache: true
      }
    },
    // 币币管理
    {
      path: '/currcoin/orderslist',
      name: 'currcoinorder',
      authority: 'currcoinorder',
      component: () => import('../views/currcoin/orderslist'),
      meta: {
        title: '订单列表',
        noCache: true
      }
    },
    ...Money,
    ...platform,
    ...game,
    // {
    //   path: '/customer/list',
    //   name: 'customer',
    //   authority: 'customer',
    //   component: () => import('../views/customer'),
    //   meta: {
    //     title: '用户列表',
    //     noCache: true
    //   }
    // 记录
    {
      path: '/records/order',
      name: 'recordsorder',
      authority: 'recordsorder',
      meta: { title: '资金流水', noCache: true },
      component: () => import('@/views/records/order.vue')
    },
    {
      path: '/records/benefits',
      name: 'recordsbenefits',
      authority: 'recordsbenefits',
      meta: { title: '资金流水', noCache: true },
      component: () => import('@/views/records/benefits.vue')
    },
    // 数据
    {
      path: '/data/dig',
      name: 'datadig',
      authority: 'datadig',
      meta: { title: '挖矿收益配置', noCache: true },
      component: () => import('@/views/data/dig.vue')
    },
    {
      path: '/data/share',
      name: 'datashare',
      authority: 'datashare',
      meta: { title: '分享收益配置', noCache: true },
      component: () => import('@/views/data/share.vue')
    },
    {
      path: '/data/pool',
      name: 'datapool',
      authority: 'datapool',
      meta: { title: '矿池收益配置', noCache: true },
      component: () => import('@/views/data/pool.vue')
    },
    {
      path: '/event/list',
      name: 'eventlist',
      authority: 'eventlist',
      meta: { title: '竞技赛列表', noCache: true },
      component: () => import('@/views/event/list.vue')
    },
    // 运营
    {
      path: '/placfg/notice',
      name: 'placfgnotice',
      authority: 'placfgnotice',
      component: () => import('../views/placfg/banner.vue'),
      meta: {
        title: '轮播管理',
        noCache: true
      }
    },
    {
      path: '/placfg/posters',
      name: 'placfgposters',
      authority: 'placfgposters',
      component: () => import('../views/placfg/posters.vue'),
      meta: {
        title: '公告管理',
        noCache: true
      }
    },
    {
      path: '/placfg/aper',
      name: 'placfgaper',
      authority: 'placfgaper',
      component: () => import('../views/placfg/aper.vue'),
      meta: {
        title: '平台配置',
        noCache: true
      }
    },
    {
      path: '/placfg/airplane',
      name: 'placfgairplane',
      authority: 'placfgairplane',
      component: () => import('../views/placfg/airplane.vue'),
      meta: {
        title: ' 软件包列表',
        noCache: true
      }
    },
    {
      path: '/placfg/email',
      name: 'placfgemail',
      authority: 'placfgemail',
      component: () => import('../views/placfg/email.vue'),
      meta: {
        title: '邮箱',
        noCache: true
      }
    }

  ]
}]

export default new Router({
  mode: 'history',
  base: '/cpd_mng/',
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})
